package main

import "unsafe"

// MICryptObj 加解密对象.
type MICryptObj struct {
	instance unsafe.Pointer
}

// NewMICryptObj 创建加解密对象.
func NewMICryptObj() *MICryptObj {
	return &MICryptObj{
		instance: GetSafeHandle(),
	}
}

// Free 释放.
func (mi *MICryptObj) Free() {
	FreeSafeHandle(mi.instance)
}

// TransEncrypt 加密.
func (mi *MICryptObj) TransEncrypt(src []byte) []byte {
	return TransEncrypt(mi.instance, src)
}

// TransDecrypt 解密.
func (mi *MICryptObj) TransDecrypt(src []byte) ([]byte, error) {
	return TransDecrypt(mi.instance, src)
}
